/** 
* Copyright (C) 2012-2017 ZEEI Inc.All Rights Reserved.
* 项目名称：pls
* 文件名称：PointController.java
* 包  名  称：com.zeei.app.controller
* 文件描述：TODO 请修改文件描述
* 创建日期：2017年12月19日上午9:04:47
* 
* 修改历史
* 1.0 chenhuiqiong 2017年12月19日上午9:04:47 创建文件
*
*/

package com.zeei.app.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.zeei.app.constant.PointConstant;
import com.zeei.app.service.GasPointService;
import com.zeei.app.service.WatPointService;
import com.zeei.app.vo.AppPointResultVO;
import com.zeei.app.vo.GasPointListVO;
import com.zeei.app.vo.GasPointPolluteLimitInorg;
import com.zeei.app.vo.GasPointPolluteLimitSpecial;
import com.zeei.app.vo.GasPolluteCountVO;
import com.zeei.app.vo.QueryParamVO;
import com.zeei.app.vo.WatPointPolluteLimit;
import com.zeei.app.vo.WatPointPolluteLimitSpecial;
import com.zeei.app.vo.WatPolluteCountVO;
import com.zeei.app.vo.WaterPointListVO;
import com.zeei.common.annotation.SysLog;
import com.zeei.common.controller.BasicController;
import com.zeei.common.enums.LogType;
import com.zeei.common.vo.ResultDataVO;
import com.zeei.common.vo.ResultRowsVO;

/**
 * @类型名称：PointController
 * @类型描述：排口管理
 * @功能描述：排口管理
 * @创建作者：chenhuiqiong
 *
 */
@Controller
@RequestMapping("/app/enterPoint")
public class PointController extends BasicController {

    @Autowired
    private WatPointService watPointService;

    @Autowired
    private GasPointService gasPointService;

    @RequestMapping(value = "/pointInfoBySort", method = RequestMethod.POST)
    @ResponseBody
    @SysLog(text = "查询通过排口号和企业编码查询排口基本信息", type = LogType.View)
    public ResultDataVO<AppPointResultVO> queryPointInfoBySort(QueryParamVO queryParamVO) {
	AppPointResultVO appPointResultVO = new AppPointResultVO();

	if (PointConstant.WAT_POINT.equals(queryParamVO.getPointSort())) {
	    List<WaterPointListVO> watList = queryWatPointList(queryParamVO);
	    appPointResultVO.setWatList(watList);
	} else if (PointConstant.GAS_POINT.equals(queryParamVO.getPointSort())) {
	    List<GasPointListVO> gasList = queryGasPointList(queryParamVO);
	    appPointResultVO.setGasList(gasList);
	}else{
	    List<GasPointListVO> gasList = queryGasPointList(queryParamVO);
	    List<WaterPointListVO> watList = queryWatPointList(queryParamVO);
	    
	    appPointResultVO.setGasList(gasList);
	    appPointResultVO.setWatList(watList);
	}
	return createResultDataVO(appPointResultVO, true, "");
    }

    /**
     * 
     * queryWatPointList:查询废水排口信息
     * 
     * @param queryParamVO
     * @return List<WaterPointListVO>
     */
    private List<WaterPointListVO> queryWatPointList(QueryParamVO queryParamVO) {
	WaterPointListVO waterPointListVO = new WaterPointListVO();
	waterPointListVO.setPointCode(queryParamVO.getPointCode());
	waterPointListVO.setPsCode(queryParamVO.getPsCode());
	waterPointListVO.setPointDirect(queryParamVO.getPointDirect());
	List<WaterPointListVO> watList = watPointService.queryPointInfo(waterPointListVO);
	return watList;
    }

    /**
     * 
     * queryGasPointList:查询废气排口信息
     * 
     * @param queryParamVO
     * @return List<GasPointListVO>
     */
    private List<GasPointListVO> queryGasPointList(QueryParamVO queryParamVO) {
	GasPointListVO gasPointListVO = new GasPointListVO();
	gasPointListVO.setPointCode(queryParamVO.getPointCode());
	gasPointListVO.setPsCode(queryParamVO.getPsCode());
	List<GasPointListVO> gasList = gasPointService.queryPointInfo(gasPointListVO);
	return gasList;
    }

    @RequestMapping(value = "/gasPointInfo", method = RequestMethod.POST)
    @ResponseBody
    @SysLog(text = "查询废气排口信息", type = LogType.View)
    public ResultRowsVO<GasPointListVO> queryGasPointInfo(GasPointListVO gasPointListVO) {
	List<GasPointListVO> gasList = gasPointService.queryPointInfo(gasPointListVO);
	return createResultRowsVO(gasList, true, "", gasList.size());
    }

    
    @RequestMapping(value = "/gasPolluteCount", method = RequestMethod.POST)
    @ResponseBody
    @SysLog(text = "废气排放统计信息", type = LogType.View)
    public ResultRowsVO<GasPolluteCountVO> queryGasPointInfo(GasPolluteCountVO gasPolluteCount) {
	List<GasPolluteCountVO> gasList = gasPointService.queryGasPolluteCount(gasPolluteCount);
	return createResultRowsVO(gasList, true, "", gasList.size());
    }
    
    @RequestMapping(value = "/gasPointLimitSpecialInfo", method = RequestMethod.POST)
    @ResponseBody
    @SysLog(text = "查询废气排放特殊情况排放许可限值", type = LogType.View)
    public ResultRowsVO<GasPointPolluteLimitSpecial> queryGasPointPolluteLimitSpecial(GasPointPolluteLimitSpecial gasPointPolluteLimitSpecial) {
	List<GasPointPolluteLimitSpecial> polluteLimitSpecialList = gasPointService.queryGasPointPolluteLimitSpecial(gasPointPolluteLimitSpecial);
	return createResultRowsVO(polluteLimitSpecialList, true, "", polluteLimitSpecialList.size());
    }
    
    @RequestMapping(value = "/gasPointLimitInorgInfo", method = RequestMethod.POST)
    @ResponseBody
    @SysLog(text = "查询废气排放无组织排放许可限值", type = LogType.View)
    public ResultRowsVO<GasPointPolluteLimitInorg> queryGasPointPolluteLimitInorg(GasPointPolluteLimitInorg gasPointPolluteLimitInorg) {
	List<GasPointPolluteLimitInorg> polluteLimitInorgList = gasPointService.queryGasPointPolluteLimitInorg(gasPointPolluteLimitInorg);
	return createResultRowsVO(polluteLimitInorgList, true, "", polluteLimitInorgList.size());
    }
    
    @RequestMapping(value = "/gasPointTotalLimitInfo", method = RequestMethod.POST)
    @ResponseBody
    @SysLog(text = "排污单位大气排放总许可量", type = LogType.View)
    public ResultRowsVO<GasPointPolluteLimitInorg> queryGasPolluteTotalLimit(GasPointPolluteLimitInorg gasPointPolluteLimitInorg) {
	List<GasPointPolluteLimitInorg> polluteTotalLimitList = gasPointService.queryGasPolluteTotalLimit(gasPointPolluteLimitInorg);
	return createResultRowsVO(polluteTotalLimitList, true, "", polluteTotalLimitList.size());
    }
    
    @RequestMapping(value = "/watPointInfo", method = RequestMethod.POST)
    @ResponseBody
    @SysLog(text = "查询废水排口信息", type = LogType.View)
    public ResultRowsVO<WaterPointListVO> queryGasPointInfo(WaterPointListVO waterPointListVO) {
	List<WaterPointListVO> watList = watPointService.queryPointInfo(waterPointListVO);
	return createResultRowsVO(watList, true, "", watList.size());
    }
    
    @RequestMapping(value = "/watPolluteLimit", method = RequestMethod.POST)
    @ResponseBody
    @SysLog(text = "查询废水排口排放许可限值", type = LogType.View)
    public ResultRowsVO<WatPointPolluteLimit> queryWatPointPolluteLimit(WatPointPolluteLimit watPointPolluteLimit) {
	List<WatPointPolluteLimit> watPolluteLimitList = watPointService.queryWatPointPolluteLimit(watPointPolluteLimit);
	return createResultRowsVO(watPolluteLimitList, true, "", watPolluteLimitList.size());
    }
    
    @RequestMapping(value = "/watPolluteLimitSpecial", method = RequestMethod.POST)
    @ResponseBody
    @SysLog(text = "查询废水排口特殊排放许可限值", type = LogType.View)
    public ResultRowsVO<WatPointPolluteLimitSpecial> queryWatPointPolluteLimitSpecial(WatPointPolluteLimitSpecial watPointPolluteLimitSpecial) {
	List<WatPointPolluteLimitSpecial> watPolluteLimitSpecialList = watPointService.queryWatPointPolluteLimitSpecial(watPointPolluteLimitSpecial);
	return createResultRowsVO(watPolluteLimitSpecialList, true, "", watPolluteLimitSpecialList.size());
    }
    
    @RequestMapping(value = "/watPolluteCount", method = RequestMethod.POST)
    @ResponseBody
    @SysLog(text = "查询废水排口合计信息", type = LogType.View)
    public ResultRowsVO<WatPolluteCountVO> queryWatPointPolluteCount(WatPolluteCountVO watPolluteCountVO) {
	List<WatPolluteCountVO> watPolluteCountList = watPointService.queryWatPointPolluteCount(watPolluteCountVO);
	return createResultRowsVO(watPolluteCountList, true, "", watPolluteCountList.size());
    }
}
